let scrollTop;
let btn = document.getElementsByClassName('back-top')[0];
window.onscroll = function (){
  /* 考虑兼容问题 */
  scrollTop = document.documentElement.scrollTop || document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
  if(scrollTop >= 80){
    btn.style.opacity = '1';
  }else{
    btn.style.opacity = '0';
  }
}
function backTop(){
  /* 返回顶部的动画 */
  let topTimer = setInterval(() => {
    console.log(1);
    if(scrollTop > 0){
      scrollTop -= 60;
      scrollTo(0, scrollTop);
    }else{
      clearInterval(topTimer);
    }
  }, 5)
}